package com.sdgakj.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by eiffel on 2017-04-07.
 */
@Entity
@Table(name = "f_person")
public class Person extends IdEntity implements Serializable{
    private static final long serialVersionUID = 1L;
    /**对应数据库字段
     id	bigint	11	0	0	-1	0	0	0		0					-1	0
     family_name	varchar	255	0	-1	0	0	0	0		0	姓	utf8	utf8_general_ci		0	0
     name	varchar	20	0	0	0	0	0	0		0	名	utf8	utf8_general_ci		0	0
     gender	varchar	255	0	-1	0	0	0	0		0	性别	utf8	utf8_general_ci		0	0
     age	varchar	11	0	-1	0	0	0	0		0	年龄	utf8	utf8_general_ci		0	0
     alive	int	255	0	-1	0	0	0	0		0	是否在世 0去世 1在世				0	0
     born_time	timestamp	0	0	-1	0	0	0	0		0	出生日期				0	0
     born_address	varchar	255	0	-1	0	0	0	0		0	出生地址	utf8	utf8_general_ci		0	0
     avatar	varchar	255	0	-1	0	0	0	0		0	缩略图	utf8	utf8_general_ci		0	0
     generation	varchar	255	0	-1	0	0	0	0		0	世系	utf8	utf8_general_ci		0	0
     position	int	11	0	-1	0	0	0	0		0	排行				0	0
     child_number	int	11	0	-1	0	0	0	0		0	孩子数				0	0
     parent_number	int	11	0	-1	0	0	0	0		0	父母数				0	0
     seniority	varchar	255	0	-1	0	0	0	0		0	资历	utf8	utf8_general_ci		0	0
     fu_id	int	11	0	-1	0	0	0	0		0	用户id				0	0
     bind_user	int	255	0	-1	0	0	0	0		0	是否已关联user 0未关联 1已关联				0	0
     createtime	timestamp	0	0	-1	0	0	0	0		-1	创建时间				0	0
     updatetime	timestamp	0	0	-1	0	0	0	0		-1	更新时间				0	0
     mobile	varchar	11	0	-1	0	0	0	0		0	电话	utf8	utf8_general_ci		0	0
     school	varchar	255	0	-1	0	0	0	0		0	学校	utf8	utf8_general_ci		0	0
     education	varchar	11	0	-1	0	0	0	0		0	学历	utf8	utf8_general_ci		0	0
     company	varchar	255	0	-1	0	0	0	0		0	公司	utf8	utf8_general_ci		0	0
     marry	varchar	11	0	-1	0	0	0	0	'0'	0	是否结婚  0未婚  1已婚	utf8	utf8_general_ci		0	0
     f_id	tinyint	11	0	-1	0	0	0	0	1	0	属于哪个家族				0	0
     */
    @Column(name = "family_name")
    private String familyName;//姓

    private String name;//名
    private String age;//年龄
    private Integer alive;//建在否？0 在世 1 去世
    private String description;//个人介绍
    @Column(name = "born_time")
    private String bornTime;//生日
    @Column(name = "born_address")
    private String bornAddress;//住址
    private String avatar;//缩略图
    private Integer generation;//世系
    private String position;//排行
    private String mobile;//
    private String school;//
    private String education;//教育程度
    private String company;//工作单位
    private String seniority;//资历
    private Integer marry;//是否结婚  0未婚  1已婚
    private Date updatetime;//更新时间
    private Date createtime;//创建时间
    @Column(name = "child_number")
    private Integer childNumber;//孩子数
    @Column(name = "parent_number")
    private Integer parentNumber;//父母数
    @Column(name = "bind_user")
    private Integer bindUser;//是否已关联user 0未关联 1已关联
    private User user;//对应用户
   // private Family family; //所属家族

    private String s;//性别
    private Long m;//母亲ID
    private Long f;//父亲ID
    private Long ux;//妻子ID
    private Long vir;//丈夫ID
    private String ancestralHome; //祖籍

    public String getAncestralHome() {
        return ancestralHome;
    }

    public void setAncestralHome(String ancestralHome) {
        this.ancestralHome = ancestralHome;
    }

    public String getS() {
        return s;
    }
    public void setS(String s) {
        this.s = s;
    }
    public Long getM() {
        return m;
    }
    public void setM(Long m) {
        this.m = m;
    }
    public Long getF() {
        return f;
    }
    public void setF(Long f) {
        this.f = f;
    }
    public Long getUx() {
        return ux;
    }
    public void setUx(Long ux) {
        this.ux = ux;
    }
    public Long getVir() {
        return vir;
    }
    public void setVir(Long vir) {
        this.vir = vir;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }


    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @JsonIgnore
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }

 /*   @ManyToOne(cascade={CascadeType.MERGE},fetch = FetchType.LAZY) //之前 cascadeType.All  MERGE
    @JoinColumn(name = "family_id")
    @JsonIgnore
    public Family getFamily() {
        return family;
    }
*/
 /*   public void setFamily(Family family) {
        this.family = family;
    }*/
    public Person() {
    }
    public String getFamilyName() {
        return familyName;
    }
    public void setFamilyName(String familyName) {
        this.familyName = familyName;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public Integer getAlive() {
        return alive;
    }
    public void setAlive(Integer alive) {
        this.alive = alive;
    }
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public String getBornTime() {
        return bornTime;
    }
    public void setBornTime(String bornTime) {
        this.bornTime = bornTime;
    }
    public String getBornAddress() {
        return bornAddress;
    }
    public void setBornAddress(String bornAddress) {
        this.bornAddress = bornAddress;
    }
    public String getAvatar() {
        return avatar;
    }
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
    public Integer getGeneration() {
        return generation;
    }
    public void setGeneration(Integer generation) {
        this.generation = generation;
    }
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getSchool() {
        return school;
    }
    public void setSchool(String school) {
        this.school = school;
    }
    public String getEducation() {
        return education;
    }
    public void setEducation(String education) {
        this.education = education;
    }
    public String getCompany() {
        return company;
    }
    public void setCompany(String company) {
        this.company = company;
    }
    public String getSeniority() {
        return seniority;
    }
    public void setSeniority(String seniority) {
        this.seniority = seniority;
    }
    public Integer getMarry() {
        return marry;
    }
    public void setMarry(Integer marry) {
        this.marry = marry;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdatetime() {
        return updatetime;
    }
    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreatetime() {
        return createtime;
    }
    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }
    public Integer getChildNumber() {
        return childNumber;
    }
    public void setChildNumber(Integer childNumber) {
        this.childNumber = childNumber;
    }
    public Integer getParentNumber() {
        return parentNumber;
    }
    public void setParentNumber(Integer parentNumber) {
        this.parentNumber = parentNumber;
    }
    public Integer getBindUser() {
        return bindUser;
    }
    public void setBindUser(Integer bindUser) {
        this.bindUser = bindUser;
    }
    @Override
    public String toString() {
        return "Person{" +
                "familyName='" + familyName + '\'' +
                ", name='" + name + '\'' +
                ", age='" + age + '\'' +
                ", alive=" + alive +
                ", description='" + description + '\'' +
                ", bornTime=" + bornTime +
                ", bornAddress='" + bornAddress + '\'' +
                ", avatar='" + avatar + '\'' +
                ", generation='" + generation + '\'' +
                ", position='" + position + '\'' +
                ", mobile='" + mobile + '\'' +
                ", school='" + school + '\'' +
                ", education='" + education + '\'' +
                ", company='" + company + '\'' +
                ", seniority='" + seniority + '\'' +
                ", marry=" + marry +
                ", updatetime=" + updatetime +
                ", createtime=" + createtime +
                ", childNumber=" + childNumber +
                ", parentNumber=" + parentNumber +
                ", bindUser=" + bindUser +
                ", user=" + user +
                '}';
    }
}
